import { defineStore } from 'pinia'
import { userLoginApi, userInfoApi } from '../api/user.ts'
import { FormState } from '../type/user.ts'


export const useUserStore = defineStore('user', {

  state: () => {
    return {
      //登录返回的个人信息,用于登录提示，不持久
      userInfo: {} as any,
      //持久的个人信息
      userInfoZhen: {} as any
    }
  },

  actions: {
    //用户登录
    async userLogin(userFrom: FormState) {
      const res = await userLoginApi(userFrom)
      this.userInfo = res

     
    },

    //用户全局信息
    async userInfoM() {
      const res = await userInfoApi();
      this.userInfoZhen = res.data
      
    }


  }



})